 {{include file="../tools/jquery_validator2.htm"}}

<div class="userbox">
  <h2>青币管理</h2>
  <form  id="gold" method="post">
    <div class="left left0">
      <div class="nameorange" ></div>
      <table class="jifentablet">
         <tr>
          <td colspan="3" class="bordernone">查看明细</td>
        </tr>
        {{foreach from=$gold_log item=list key=key}}
         <tr {{if $key%2==0}}class="odd"{{/if}}>
          <td class="width1"><small>{{$list.add_time}}</small></td>
          <td class="width2">
          {{$comment = $list.comment|replace:"积分":"青币"}} 
          {{if $g==$list.buyer}}
			  {{$comment|replace:"收入":"支出"}}  
          {{else}}
          	  {{$comment|replace:"支出":"收入"}}  
          {{/if}} 
          </td>
          <td class="width3 bordernone"> <strong class="greent">{{if $list.amount>0}}{{if $g==$list.buyer}}-{{else}}+{{/if}} {{/if}}{{$list.amount}}</strong></td>
        </tr>
        {{/foreach}}
       
      
      </table>
      <div class="icobtn">
      	
       
      </div>
    </div>
  </form>
 
 
 <div class="right">
    <p class="information">目前可用青币:</p>
    <p class="information" style="padding:0 0 0 100px;font-size:30px"><span class="colorred">{{$user_info.gold}}</span></p>
  
  </div>
  <!--right end--> 
  {{include file="../pager.htm"}}
</div>
<script>
	

//店铺内发送金币给店员
 function setGold(){
	 var data = new Object;
	 var cat_gold = '{{$cat.gold}}';
	 data.buyer = '{{$cat.cat_id}}';
	 data.geter = $("select[name=user_id]").val();
	 data.add_type = encodeURIComponent("+");
	 data.type = '2';
	 data.amount = $("input[name=amount]").val();
	 var comment= $("input[name=comment]").val();
	 if(data.geter=='')
	 {
		alert("请选择店员!");
		return false;	 
	 }
	 if((cat_gold-data.amount >0) && chk.isInteger(data.amount))
	 {
		 var geter_text = $("select[name=user_id]").find("option:selected").text();
		 data.comment = (comment =='备注...') ? '{{$cat.cat_name}} 分配给 '+geter_text+' '+data.amount+' 青币 操作人:{{$session.user_info.user_name}}' : comment;
		 var da = "act=send_gold&data="+$.toJSON(data);
		 Main.AJAX(sep+"/ajax.php",da,setGoldRes)
	 }
	 else
	 {
		alert("您输入的金额不正确，请重新输入!");	 	 
	 }
  }
  
 function setGoldRes(res){
	if(res=='1')
	{
		alert('操作成功!');
		location.href = location.href;	
	}
	else
	{
		alert("操作失败，请重试");
		location.href = location.href;	
	}
 }
  
 
</script>